/** ###################################################################
**     Filename  : MMA7455.H
**     Project   : project_xgate
**     Processor : MC9S12XDT512BMFU
**     Compiler  : CodeWarrior HCS12X C Compiler
**     Date/Time : 5/1/2009, 1:30 AM
**     Contents  :
**         User source code
**
**     (c) Copyright UNIS, a.s. 1997-2008
**     UNIS, a.s.
**     Jundrovska 33
**     624 00 Brno
**     Czech Republic
**     http      : www.processorexpert.com
**     mail      : info@processorexpert.com
** ###################################################################*/

#ifndef __MMA7455_H
#define __MMA7455_H

/* MODULE MMA7455 */
typedef unsigned char byte;
typedef unsigned int word;
typedef unsigned long dword;
typedef unsigned long dlong[2];
// ION MODES (MEASURE)
#define ION_MEASURE 1
#define ION_STANDBY 0

//ION G_SELECT VALUES
#define ION_G2 0b01                       // 2g range        
#define ION_G4 0b10                       // 4g range
#define ION_G8 0b00                       // 8g range

//ION AUTOCALIBRATION PROCESS
#define MAX_CNT_RUNS 55  

typedef struct accel_vector{
 signed char X;
 signed char Y;
 signed char Z;  
}vector_t;

void MMA7455_getVector(vector_t *myVec);

void StaticCalibration_Ion();
void MMA7455_writeReg(unsigned char Addr, unsigned char data);
char MMA7455_readReg(unsigned char Addr);
void Read_AccelerometerIon(void);
void ReadAllIonRegisters(void);
void Init_SensorIon(void);
void SetUp_GselectIon(byte);
void SetUp_ModeOfSensorIon(byte);
void Ion_SwitchMode(byte mode);
byte AutoCalibration_Ion(void);
void Dummy_Pointer(byte, void *dummy, byte);
void Set_SelfTest(void);
void Clear_SelfTest(void); 
void ReadIonXOUTL(void); 
void ReadIonXOUTH(void); 
void ReadIonYOUTL(void); 
void ReadIonYOUTH(void); 
void ReadIonZOUTL(void); 
void ReadIonZOUTH(void); 
void ReadIonXOUT8(void); 
void ReadIonYOUT8(void);  
void ReadIonZOUT8(void); 
void ReadIonSTATUS(void); 
void ReadIonDETSR(void); 
void ReadIonTOUT(void); 
void ReadIonI2CAD(void);  
void ReadIonUSRINF(void); 
void ReadIonWHOAMI(void); 
void ReadIonXOFFL(void); 
void ReadIonXOFFH(void);  
void ReadIonYOFFL(void); 
void ReadIonYOFFH(void);  
void ReadIonZOFFL(void);  
void ReadIonZOFFH(void); 
void ReadIonINTRST(void); 
void ReadIonMCTL(void);  
void ReadIonCTL1(void);
void ReadIonCTL2(void); 
void ReadIonLDTH(void); 
void ReadIonPDTH(void); 
void ReadIonPW(void);  
void ReadIonLT(void); 
void ReadIonTW(void); 

/* END MMA7455 */

#endif

